package com.yiwyn.ood.ocp;

public class OCPBadDemo {

    public static void main(String[] args) {
        GraphicEditor editor = new GraphicEditor();
        // 画一个圆形
        editor.draw("Circle");
    }

    // 图形编辑类
    static class GraphicEditor {

        // 画图方法
        public void draw(String graphicType) {
            if (graphicType.equals("Circle")) {
                final OCPGoodDemo.Circle circle = new OCPGoodDemo.Circle();
                circle.draw();
            } else if (graphicType.equals("Rectangle")) {
                final OCPGoodDemo.Rectangle rectangle = new OCPGoodDemo.Rectangle();
                rectangle.draw();
            }
        }
    }

    // 圆形
    static class Circle {
        public void draw() {
            System.out.println("画一个圆形");
        }
    }

    // 矩形
    static class Rectangle {

        public void draw() {
            System.out.println("画一个矩形");
        }

    }
}


